from selenium import webdriver
from selenium.webdriver.common.by import By
import pytest,time

@pytest.fixture()
#定义driver方法
def driver():
    driver = webdriver.Edge()
    driver.maximize_window()
    yield driver
    driver.quit()

#定义测试用例
def test_a3mall_01(driver):
    driver.get('http://10.59.9.12:7001/')              #打开a3mall网址
    #点击右上方请登录
    driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
    time.sleep(5)
    #断言1————会员登录
    dy1 = driver.find_element(By.CLASS_NAME,'reg-new').text
    print(dy1)
    time.sleep(3)
    #输入用户名
    driver.find_element(By.XPATH,'//input[@class="regi-input"and@name="username"]').send_keys('13811033962')
    #输入密码
    driver.find_element(By.XPATH,'//input[starts-with(@name,"password")]').send_keys('123456')
    time.sleep(8)
    #点击登录按钮
    driver.find_element(By.XPATH,'/html/body/div[4]/div/div[1]/div[2]/form/div[5]/a').click()
    time.sleep(5)
    #断言2————欢迎回来，13811033962
    dy2 = driver.find_element(By.XPATH,'//a[@href="/home/ucenter/index.html"]').text
    print(dy2)
    time.sleep(5)